from playwright.sync_api import sync_playwright
from common.config import Config


class DriverFactory:
    def __init__(self):
        self.playwright = sync_playwright().start()
        self.browser = getattr(self.playwright, Config.BROWSER).launch(headless=Config.HEADLESS)
        self.context = self.browser.new_context()
        self.page = self.context.new_page()

    def get_page(self):
        return self.page

    def quit(self):
        self.browser.close()
        self.playwright.stop()